package com.loop.stringDemo;

/**
 * String 类的replace，split，trim 方法的使用
 */
public class StringOther {
    public static void main(String[] args) {
        String a= "abcd";
        String b = "HelloWorld";
        System.out.println(a.replace("a","c"));
        System.out.println(b.replace("o","*"));

        String c = "20000-212-213";
        String[] split = c.split("-");
        for (int i = 0; i < split.length; i++) {
            System.out.println(split[i]);
        }

        String d = "   尼古拉斯赵四    ";
        System.out.println(d.trim()+"yyds");


        /**
         * 将前后中间都带空格的字符串去掉空格
         */
        String zs = " 张 三 ";
        String[] s = zs.trim().split(" ");
        String newZs ="";
        for (int i = 0; i < s.length; i++) {
            newZs += s[i];
        }
        System.out.println(newZs);
    }
}
